<template>
  <div>
    {{ times(2, constant({ id: 1, name: "张三" }))[0] }}
  </div>
</template>

<script setup lang="ts">
import {
  constant,
  filter,
  get,
  isEqual,
  keyBy,
  map,
  matches,
  method,
  methodOf,
  set,
  times,
  toNumber,
  unionBy,
  countBy,
  uniqWith,
} from "lodash-es";
import { count } from "echarts/types/src/component/dataZoom/history";

console.log(get({ a: { b: { c: 123 } } }, ["a", "b", "c"]));
console.log(set(1, ["a", "b", "c"], "HAHAHA"));
console.log(toNumber(""));

const users = [
  {
    id: 1,
    name: "张三",
    a: {
      b: {
        c: 2,
      },
    },
  },
  {
    id: 2,
    name: "李四",
  },
  {
    id: 3,
    name: "王五",
  },
];
console.log(filter(users, matches({ id: 1, name: "张三" })));

console.log(times(10, constant({ id: 1, name: "张三" })));
// console.log(filter(users, method("name")));
console.log(map(users, "a.b.c"));

// Use of _.methodOf() method
var array = times(4, constant);

const gfg = map(
  ["geeks[1]", "geek[2]"],
  methodOf({
    www: array,
    geeks: array,
    for: array,
    geek: array,
  }),
);

// Printing the output
console.log(
  methodOf({
    geeks: array,
  })("geeks['2']"),
);
console.log(unionBy([{ name: "tusuzer" }, { name: "tusuzer" }], "name"));
console.log(uniqWith([1, 2, 3, 4, 2, 3, 4, 1], (a, b) => a == b));
console.log(countBy([1, 2, 3, 4, 5, 6, 1, 2, 3]));
console.log(
  filter(countBy([1, 2, 1, 2, 3, 3, 3, 4]), (value, key) => {
    // console.log(value, key);
    return value == 1;
  }),
);

console.log(countBy([2, 2, 3, 2]));
console.log(
  filter({ 1: 1, 2: 3 }, (value, key) => {
    return value == 3;
  }),
);
console.log(
  isEqual(
    {
      a: 1,
      desc: {
        name: "tusuzer",
      },
    },
    {
      a: 1,
      desc: {
        name: "tusuzer",
      },
    },
  ),
);
</script>

<style scoped></style>
